<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>支付加载中</title>
    <link rel="stylesheet" href="__PUBLIC__/Home/css/cart.css?v=20170411001">
    <include file="Public/common_js"/>
</head>
<body style="background: white">
<input type="hidden" id="order_num" value="{$order_num}">
<div class="warp">
    <div class="payLoading" id="loadingDiv">
        <img class="" src="/Public/Home/images/pay-loading.gif" >
    </div>
</div>
<script type="text/javascript">
    require(['base']);
    var oldAjaxObj = null;
    var isAbort = false;
    var i = 0;
    setTimeout(inspectOrder, 1);
    function inspectOrder(){
        if(oldAjaxObj){
            isAbort = true;
            oldAjaxObj.abort();
        }
        isAbort = false;
        oldAjaxObj = $.ajax({
            url:"{:U('Pay/inspectOrder')}",
            type:'post',
            datatype:'json',
            data:{'order_num':$('#order_num').val()},
            success:function (rs) {
                console.log(rs);
                if(rs["status"]){
                    if(rs.type == 1){
                        window.location.href="{:url('Pay/paySuccess',['order_num'=>$order_num,'type'=>$pay_type])}";
                    }else if(rs.type == 2){
                        window.location.href="{:url('Pay/payFail',['order_num'=>$order_num,'type'=>$pay_type])}";
                    }
                }
            },
            error:function (err) {
                if(!isAbort){
                    _global.promote.alertPopup("服务器异常，请稍后重试！");
                }
            }
        });
        setTimeout(inspectOrder,1000);
    }
</script>
</body>
</html>